package com.kuaiying.kuai.ying.model.school;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.kuaiying.kuai.ying.model.print_shop.PrintshopModel;
import com.kuaiying.kuai.ying.model.user.UserModel;

public class SchoolModel extends Model<SchoolModel>{

	private static final long serialVersionUID = -6984293973714614241L;
	
	public static final SchoolModel me = new SchoolModel();
	
	private static final String USER_CACHE = "shop";
	
	public SchoolModel(){
		super( );
	}
	/**
	 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public Page<SchoolModel> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from   order by id asc");
	}
	
	/**
	 * 根據用戶名和用戶密碼驗證用戶是否存在
	 * @param userName：用戶名
	 * @param pwd：用戶密碼
	 * @return：用戶信息或null
	 */
	public List<SchoolModel> getSchool(){
		String sql = "select * from school ORDER BY school_id";
		System.out.println( sql );
		
		List<SchoolModel> schools = me.find(sql);
		
		return schools;
	}
	

	public int compareTo(Object o)
	{

		   SchoolModel sdto = (SchoolModel)o;

	       int otherschoolid = sdto.me.get("school_id");
	      // note: enum-type's comparation depend on types' list order of enum method
	      // so, if compared property is enum-type ,then its comparationfollow ObjEnum.objType order


	      return this.me.getInt("school_id").compareTo(otherschoolid);
	}

}


